package com.shujia.Day07;

import java.util.Arrays;

public class Demo05StringFunction2 {
    public static void main(String[] args) {
        /*
            TODO 字符串方法
                转换功能
                byte[] getBytes()
                char[] toCharArray()
                static String valueOf(char[] chs)
                static String valueOf(int i)
                String toLowerCase()
                String toUpperCase()
                String concat(String str)
         */
        String str = "abcd";
        byte[] bytes = str.getBytes();
        System.out.println(Arrays.toString(bytes)); // [97, 98, 99, 100]

        /*
            对于一个中文默认占用三个字节数据
         */
        String str2 = "字符串"; // => [-27, -83, -105, -25, -84, -90, -28, -72, -78]
        System.out.println(Arrays.toString(str2.getBytes()));

         /*
            对于一个中文默认占用一个字符数据
         */
        char[] chars = str2.toCharArray();
        System.out.println(Arrays.toString(chars));
        System.out.println(str.toCharArray());

        char[] chars2 = {'数','组'};
        String char2Str = String.valueOf(chars2);
        System.out.println(char2Str);

        System.out.println(str.toUpperCase());
        System.out.println(str.toUpperCase().toLowerCase());
        // hello
        String hello = "helLo"; // => Hello
        String takeStr = hello.substring(1).toLowerCase();
//        String headStr = hello.substring(0, 1).toUpperCase();
        String headStr = String.valueOf(hello.charAt(0)).toUpperCase();
        System.out.println(headStr+takeStr);

        String str3 = "head";
        String str4 = "tail";
        System.out.println(str3+","+str4);
        System.out.println(str3.concat(",").concat(str4));


    }
}
